import { getBannerList } from "@/api/home.js";

export default {
  namespaced: true,
  state: {
    isLoading: false,
    bannerList: [],
  },
  mutations: {
    setLoading(state, payload) {
      state.isLoading = payload;
    },
    setBannerList(state, payload) {
      state.bannerList = payload;
    },
  },
  actions: {
    async fetchBannerList(ctx) {
      ctx.commit("setLoading", true);
      const res = await getBannerList();
      ctx.commit("setLoading", false);
      if (res.code === 0) {
        ctx.commit("setBannerList", res?.data || []);
      }
      return res;
    },
  },
};
